package com.hoshiicloud.as2c.minipro.feign;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.as2c.minipro.dto.ExtSpuDto;
import com.hoshiicloud.as2c.minipro.dto.ExtSpuTagsDto;
import com.hoshiicloud.as2c.minipro.feign.hystrix.HystrixGoodsFeignFallback;
import com.hoshiicloud.as2c.minipro.param.ExtSkuQueryParam;
import com.hoshiicloud.as2c.minipro.param.ExtSpuQueryParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;
import java.util.Map;

/**
 * @author yangcheng
 * @version 1.0
 * @title: GoodsFeignService
 * @description: 商品微服务FeignClient
 * @date 2019/6/4 15:35
 * @mail maiboyc@163.com
 */
@FeignClient(name = "hoshiicloud-goods", fallback = HystrixGoodsFeignFallback.class)
public interface GoodsFeignService {

    /**
     * 分页获取扩展spu信息
     * @param param 查询参数
     * @return Response<Page<ExtSpuDto>>
     */
    @RequestMapping(value = "/goods/ext-spu/query/page")
    Response<Page<ExtSpuDto>> page(@RequestBody ExtSpuQueryParam param);

    /**
     * 查询商品列表
     * @param param 查询参数
     * @return  Response<Page<Map<String,Object>>>
     */
    @RequestMapping(value = "/goods/ext-spu/query/list", method = RequestMethod.POST)
    Response<Page<Map<String,Object>>> getSpusWithMiniPrice(@RequestBody ExtSpuQueryParam param);

    /**
     * 根据类目查询商品列表
     * @param param 查询参数
     * @return  Response<Page<Map<String,Object>>>
     */
    @RequestMapping(value = "/goods/ext-spu/query/listCategoryId", method = RequestMethod.POST)
    Response<Page<Map<String,Object>>> getSpusByStoreIdAndCategoryId(@RequestBody ExtSpuQueryParam param);

    /**
     * 查询商品详情
     * @param id ID
     * @return  Response<Map<String,Object>>
     */
    @RequestMapping(value = "/goods/ext-spu/detail/{id}", method = RequestMethod.GET)
    Response<List<Map<String,Object>>> getGoodsDetail(@PathVariable("id") Long id);

    /**
     * 根据spuId获取标签信息
     * @param spuId 商品spuId
     * @return Response<List<ExtSpuTagsDto>>
     */
    @RequestMapping(value = "/goods/ext-spu-tags/getBySpuId/{spuId}", method = RequestMethod.GET)
    Response<List<ExtSpuTagsDto>> getTagsBySpuId(@PathVariable("spuId") Long spuId);

    /**
     * 根据ID获取标签信息
     * @param id ID
     * @return Response<ExtSpuTagsDto>
     */
    @RequestMapping(value = "/goods/ext-spu-tags/{id}", method = RequestMethod.GET)
    Response<ExtSpuTagsDto> getTagById(@PathVariable("id") Long id);

    /**
     * 根据spuid获取sku最低价
     * @param param 查询参数
     * @return Response<Map<String,Object>>
     */
    @RequestMapping(value = "/goods/ext-sku/listSkuMiniPrice", method = RequestMethod.POST)
    Response<Map<String,Object>> listSkuMiniPrice(@RequestBody ExtSkuQueryParam param);

}
